package com.epam.android.training.day4day5.task2;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.Spinner;

/**
 * Support activity of task2-4 with custom defined theme, stateful drawable
 * suppored views and ability to create {@link CityListActivity} with a list of
 * cities in a list view.
 * 
 * @author Anton Novikau
 */
public class SupportActivity extends Activity {

    /** Called when the activity is first created. */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.support);

        Spinner citySpinner = (Spinner) findViewById(R.id.city);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.city,
                android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        citySpinner.setAdapter(adapter);

        ImageButton showCitiesButton = (ImageButton) findViewById(R.id.show_list_view);
        showCitiesButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SupportActivity.this, CityListActivity.class);
                startActivity(intent);
            }
        });
    }
}
